﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Engine
{
    /// <summary>
    /// The class represents a c# class
    /// </summary>
    public class Class
    {
        public String Name { get; set; }
        public IEnumerable<Property> Properties { get; set; }
        public List<Method> Methods { get; set; }

        public Class()
        {
            this.Properties = new List<Property>();
            this.Methods = new List<Method>();
        }

        /// <summary>
        /// Write the .m file
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            String m = string.Empty;
            StringBuilder sb = new StringBuilder();

            //Build h file
            sb.AppendLine();
            sb.AppendLine("//Converted by dugongsoftware at codeplex.com ");
            sb.AppendLine("//");
            sb.AppendLine(String.Format("#import {0}.h", this.Name));
            sb.AppendLine();
            sb.AppendFormat("@implementation {0}", this.Name);
            sb.AppendLine();
            sb.AppendLine("{");

            //
            foreach (Method method in this.Methods)
            {
                //
            }

            sb.AppendLine();

            //Do properties
            foreach (Property property in Properties)
            {
                sb.AppendLine(String.Format("@synthesize {0};", property.Name));
            }

            //Close
            sb.AppendLine();
            sb.AppendLine("}");
            sb.AppendLine();
            sb.AppendLine("@end");

            return sb.ToString();
        }
    }
}
